<extend name="Public/base"/>

<block name="body">
    <script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>

    <style>
        .tab-content .form-item{margin-top: 10px;}
        .comment_img img{width:200px; height: 150px; margin-right:10px;}
        .comment_title>span{margin-right:30px; font-size: 15px;}
        .pinglun_list .userfz{ margin-right: 20px;}
        .pinglun_list{ min-height: 60px;  padding-top:10px;padding-bottom: 10px;margin-left:30px; border-bottom: 1px dashed #D4CFCF; }
        .btn_save,.btn_delete{color: red;margin-left:10px; cursor: pointer; margin-left:5px;}
        .btn_save:hover,.btn_delete:hover{text-decoration: underline;}
        .small_comment{width:75%;float: left;}
        .reply_btn2{ float: left; width: 20%;height: 34px;margin-left: 5px;}
        .cont_2{display: block}
        .cont_2:after{content: '';display: block;clear: both;}
    </style>

    <div class="main-title">
        <h2>评论内容</h2>
    </div>
    <ul class="tab-nav nav">
        <li class="current"><a href="javascript:void(0)">基本信息</a></li>
    </ul>
        <div class="tab-content">
            <div class="form-item">
                <label class="item-label comment_title"><span>评论用户：{$list['username']}</span><span>相关商品：{$list['goods_name']}</span><span>相关商户：{$list['shop_name']}</span></label>
                <div class="controls">
                    <label class="textarea" style="width:800px;">
                        <textarea class="save_cont" data-id="{$vo['id']}" readonly="readonly">{$list['content']}</textarea>
                    </label>
                </div>
            </div>
            <div class="form-item">
                <div class="controls">
                    <div class="comment_img" style="width: 105%;height: 150px;">
                        <volist name="list['imgarr']" id="img">
                            <div class="comm_img" style="float: left;">
                                <img src="{:picture($img)}" />
                            </div>
                        </volist>
                    </div>
                </div>
            </div>

            <div class="form-item" >
                <div class="controls" style="border-top:1px solid #D4CFCF; ">
                    <volist name="son_comment" id="son">
                        <div class="pinglun_list">
                            <div class="parent" style="width: 80%; float: left; margin-left:18px;margin-top: 14px;">
                                <if condition="$son['type'] eq 2">
                                    <span class="userfz">{$list['shop_name']}</span>回复<span class="userfz">{$list['username']}:</span>
                                    <span class="cont2 cont_1">{$son['content']}<font class="btn_delete" data-id="{$son['id']}">删除</font></span>
                                    <span class="cont2 cont_2" style="display: none;"><input type="text" class="save_cont" value="{$son['content']}" style="height: 30px;" data-id="{$son['id']}" /></span>
                                <else/>
                                    <span class="userfz">{$list['username']}</span>回复<span class="userfz">{$list['shop_name']}:</span>
                                    <span class="cont2 cont_1">{$son['content']}<font class="btn_save">回复</font><font class="btn_delete" data-id="{$son['id']}">删除</font></span>
                                    <span class="cont2 cont_2" style="display: none;"><input type="text" class="small_comment"   style="height: 30px;" data-id="{$son['id']}" />
                                    <button class="btn submit-btn reply_btn2 btn6" type="button" target-form="form-horizontal">提 交</button>
                                    </span>

                                </if>
                            </div>
                        </div>
                    </volist>
                </div>
            </div>
        </div>
    <div class="tab-content" >
        <form action="{:U()}"  method="post"  class="form-horizontal"  >
            <input type="hidden" name="id" id="cid" value="{$list.id}" />
            <div class="form-item" id="reply" style="display: none;">
                <label class="item-label">回复内容：</label>
                <div class="controls">
                    <label class="textarea" style="width:800px;">
                        <textarea name="content" class="save_cont" ></textarea>

                    </label>
                </div>
            </div>
            <div class="form-item" style="margin-top: 40px;">
                <if condition="$group_id eq 10 && $list['son_status'] neq 1">
                    <button class="btn submit-btn" type="submit" id="reply_btns" style="display: none;" target-form="form-horizontal">提 交</button>
                    <button class="btn submit-btn" id="reply_btn" type="button" target-form="form-horizontal">回 复</button>
                </if>
                <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
            </div>
        </form>
    </div>
</block>

<block name="script">
    <include file="Public:datetime" />
    <script type="text/javascript" src="__STATIC__/layer/layer.js"></script>
    <script type="text/javascript">

        $('.tab-nav li').click(function(){
            $(this).attr('class','current')
                .siblings().attr('class','');
            var n_index=$('.tab-nav li').index(this);
            $('.tab-content').eq(n_index).show()
                .siblings().hide();
        });

        //导航高亮
        highlight_subnav('{:U('Goodscomment/index')}');

        $(".btn_save").click(function () {
            $(".cont_2").hide();
            $(this).parents('.parent').find('.cont_2').show();


        });
        $(".reply_btn2").click(function () {
            var comment=$(this).prev().val();
            var id = $('.small_comment').attr('data-id');
            $.post('/Admin/Goodscomment/edit',{id:id,content:comment},function (dd) {
                if(dd.status==1){
                    layer.msg(dd.info,{time:1000},function () {
                        window.location.reload();
                    });
                }else{
                    layer.msg(dd.info);
                }
            })
        });
        $(".btn_delete").click(function () {
            var id = $(this).attr('data-id');
            var obj = $(this);
            layer.confirm('确定要删除吗？', {
                btn: ['确定','取消'] //按钮
            }, function(){
                $.post('/Admin/Ajax/deleinfo',{id:id,model:'comment'},function (dd) {
                    if(dd.code==200){
                        layer.msg(dd.msg,{time:1000});
                        setTimeout(function () {
                            obj.parents('.pinglun_list').remove();
                        },1000)
                    }else{
                        layer.msg(dd.msg);
                    }
                })
            });
        });
        $("#reply_btn").click(function () {
            $(this).hide();
            $("#reply").show();
            $("#reply_btns").show();
        });
    </script>
</block>
